﻿<!doctype html>
<html>
<head>
    <meta charset="utf-8" />
    <title>企业部门记录</title>
    <!--link to style-->
    <link rel="stylesheet" href="css/adapt.css" />
    
    <link rel="stylesheet" href="../../static/css/font-awesome.min.css" />
    <!--<link rel="stylesheet" href="css/adapt.css" />-->
    <!--//End link to style-->
    <script type="text/javascript" src="../js/jquery.js"></script>
</head>
<body>
    <div class="Body clearfix">
        <div class="catlog">
            <span class="cat_block">当前位置</span>
            <span class="cat_block icon-chevron-right">部门记录</span>
            <span class="cat_block icon-chevron-right">查看部门记录</span>
        </div>
        <table class="table">
            <tr class="fir_tit">
                <td class="firline">部门编号</td>
                <td class="firline">部门名</td>
                <td class="firline">描述</td>
                <td class="firline">操作</td>
            </tr>
            
            <!--  
            <tr class="lineTr">
                <td class="reguLine">001</td>
                <td class="reguLine">商务部</td>
                <td class="reguLine">面向客户</td>
                <td class="reguLine"><span class="icon-trash span"></span></td>
            </tr>
			-->

        </table>

    </div>



    <script>
        $(function () {

        	$.ajax({
                type: "Post",
                url: "/hr_doc/servlet/DepartServlet",
                data: {
               	 Command:"list",
                },
                async: false,
                dataType: "json",
                success: function (d) {
					console.log(d);
	               	if(d.code == 1){
						
	               		var result = d.result;
	               		var str = "";
	               		for(var i = 0;i<result.length;i++){
	               			var item = result[i];
	               			
	               			str += '<tr class="lineTr">';
	               			str += '<td class="reguLine">'+item.dno+'</td>';
	               			str += '<td class="reguLine">'+item.dname+'</td>';
	               			str += '<td class="reguLine">'+item.dinfo+'</td>';
	               			str += '<td class="reguLine"><span class="icon-trash span delete" onclick="deleteDepart(\''+item.id+'\')" ></span></td>';
	               			str += '</tr>';
	               		}
	               		$(".table").append(str);
	               		
	               	}
                },
                error: function (xmlHttpRequest, textStatus, errorThrown) {
                	location.href = "/hr_doc/login.html";
                }
            });	
        	
        });
        function deleteDepart(id){
    		console.log(id);
    		$.ajax({
                type: "Post",
                url: "/hr_doc/servlet/DepartServlet",
                data: {
               	 Command:"delete",
               	 id:id
                },
                async: false,
                dataType: "json",
                success: function (d) {
					console.log(d);
	               	if(d.code == 1){
	               		alert(d.result);
	               		location.href = location.href;
	               	}
                },
                error: function (xmlHttpRequest, textStatus, errorThrown) {
                	location.href = "/hr_doc/login.html";
                }
            });
    		
    	}
    </script>
</body>
</html>